<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>修改密码</title>
<link rel="stylesheet" href="layui/css/layui.css" media="all">
</head>
<body>
	<div style="width: 700px; margin: 0 auto;">
		<div class="layui-row">
			<div class="layui-col-xs6">
				<div class="grid-demo grid-demo-bg1">
					<p>&nbsp;</p>
				</div>
			</div>
			<div class="layui-col-xs6">
				<div class="grid-demo">
					<span style="margin-right: 30px">当前用户：${sessionScope.user.name }</span>
					<a class="layui-btn layui-btn-primary layui-btn-xs"
						href="user.do?action=showUpdate">修改密码</a> <a
						class="layui-btn layui-btn-primary layui-btn-xs"
						href="user.do?action=logout">退出登录</a>
				</div>
			</div>
		</div>
		<fieldset class="layui-elem-field layui-field-title"
			style="margin-top: 20px;">
			<legend>修改密码</legend>
		</fieldset>
		<div style="margin-left: 100px;">
			<form class="layui-form layui-form-pane"
				action="user.do?action=updatePwd" method="post">
				<div class="layui-form-item">
					<label class="layui-form-label">用户名</label>
					<div class="layui-input-inline">
						<input type="text" name="username" class="layui-input"
							value="${sessionScope.user.username }"
							style="cursor: not-allowed" readonly>
					</div>
				</div>

				<div class="layui-form-item">
					<label class="layui-form-label">新密码</label>
					<div class="layui-input-inline">
						<input type="password" name="password" lay-verify="required"
							id="password1" lay-verType="tips" autocomplete="off"
							class="layui-input">
					</div>
				</div>

				<div class="layui-form-item">
					<label class="layui-form-label">确认密码</label>
					<div class="layui-input-inline">
						<input type="password" name="rePwd" lay-verify="pass2"
							id="password2" lay-verType="tips" autocomplete="off"
							class="layui-input">
					</div>
				</div>
				<%
					int s = 0;
					if (request.getAttribute("state") != null) {
						s = (int) request.getAttribute("state");
					}
					if (s == 2) {
				%>
				<div style="color: red; margin: 20px">两次输入的密码不一致，请检查</div>
				<%
					}
				%>
				<div class="layui-form-item">
					<div style="margin-left: 20px;">
						<button class="layui-btn" lay-submit="">确认修改</button>
						<button type="reset" class="layui-btn layui-btn-primary">重置</button>
						<a class="layui-btn layui-btn-primary layui-btn-radius"
							href="book.do?type=gotoindex">回主页</a>
					</div>
				</div>
			</form>
		</div>
	</div>
	<script src="layui/layui.js" charset="utf-8"></script>
	<script>
		layui.use([ 'form' ], function() {
			var form = layui.form, $ = layui.$
			form.verify({
				pass2 : function(value) {
					if ($('#password1').val() != value) {
						return '两次密码不一致';
					}
				}
			});
		});
	</script>
</body>
</html>